#!/usr/bin/env bash
if [ `uname` = 'Darwin' ]; then
  OS=osx
else
  if [ `uname` != 'Linux' ]; then
    echo "Warning: unsupported OS detected. Defaulting to Linux mode, but errors may occur." 1>&2
  fi
  OS=linux
fi
K_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

export PATH="$K_LIB_DIR/../../bin:$PATH"

source "$K_LIB_DIR/checkJava" # sets ARCH and JAVA

if [ `uname` = 'Darwin' ]; then
  export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:"$K_LIB_DIR/native/osx"
  export PATH="/usr/local/opt/bison/bin:$PATH"
else
  export PATH="$K_LIB_DIR/native/linux$ARCH":$PATH
  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$K_LIB_DIR/native/linux$ARCH"
fi

export LC_NUMERIC=C  # sets locale to C to avoid issues with numeric formats
if [ -n "${TERM}" ]; then
  export TERM;
  export K_COLOR_SUPPORT=`tput colors`
else
  export K_COLOR_SUPPORT=1
fi
